#define _CRT_SECURE_NO_WARNINGS  1
#pragma warning(disable:6031)

#include "test.h"

int SymmetricEncoding()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int x; 
		cin >> x;
		string s;
		vector<bool> hash(26, false);

		cin >> s;
		for (char ch : s)
			hash[ch - 'a'] = true;
		
		vector<int> table(256, -1);
		string r;
		for (int j = 0, index = 0; j < 26; j++)
		{
			if (hash[j])
			{
				r.push_back('a' + j);
				table['a' + j] = index++;
			}
		}

		int m = r.size();
		for (int j = 0, index = -1; j < x; j++)
		{
			char ch = s[j];
			index = table[ch];
			s[j] = r[m - 1 - index];
		}

		cout << s << endl;
	}

	return 0;
}